package com.slofzx.nuoda.evaluation.project.controller;

import com.slofzx.nuoda.evaluation.project.dto.BatchCommonDataDTO;
import com.slofzx.nuoda.evaluation.project.vo.BatchCommonDataVO;
import com.slofzx.nuoda.evaluation.project.service.BatchCommonDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.slofzx.nuoda.common.controller.BaseController;
import com.slofzx.nuoda.common.vo.AjaxResultVO;
import com.slofzx.nuoda.common.vo.PageResultVO;
import com.slofzx.nuoda.common.enums.ServiceResult;

import java.util.*;

/**
 * 评价任务公共数据控制层
 *
 * @author nuoda
 * @menu 评价任务公共数据
 * @since 2023-10-20 09:12:11
 */
@RestController
@RequestMapping("/batch_common_data")
public class BatchCommonDataController extends BaseController {
    /**
     * 服务对象
     */
    @Autowired
    private BatchCommonDataService batchCommonDataService;

    @GetMapping("/data")
    public AjaxResultVO<List<BatchCommonDataVO>> queryList(BatchCommonDataDTO dto) {
        List<BatchCommonDataVO> dataList = batchCommonDataService.queryList(dto);
        return PageResultVO.newSuccessResult(dataList, dto.getCount());
    }

    @ResponseBody
    @PostMapping(value = "/create")
    public AjaxResultVO create(@RequestBody BatchCommonDataDTO dto) {
        ServiceResult resultEnum = batchCommonDataService.create(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

    @ResponseBody
    @PostMapping(value = "/update")
    public AjaxResultVO update(@RequestBody BatchCommonDataDTO dto) {
        ServiceResult resultEnum = batchCommonDataService.update(dto);
        return AjaxResultVO.getInstance(resultEnum);
    }

    @ResponseBody
    @PostMapping(value = "/delete")
    public AjaxResultVO delete(@RequestParam String id) {
        ServiceResult resultEnum = batchCommonDataService.deleteById(id);
        return AjaxResultVO.getInstance(resultEnum);
    }

    @ResponseBody
    @GetMapping(value = "/info/{id}")
    public AjaxResultVO<BatchCommonDataVO> queryById(@PathVariable String id) {
        BatchCommonDataVO vo = batchCommonDataService.queryById(id);
        return AjaxResultVO.newSuccessResult(vo);
    }

}
